﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace BO
{
    public class Usuarios
    {
        public VO.Usuarios objVO;
        DA.Usuarios objDA;

        public Usuarios()
        {
            objDA = new DA.Usuarios();
            objVO = new VO.Usuarios();
        }

        public void Salvar()
        {
            objDA.objVO = objVO;
            objDA.Salvar();
        }

        public void Atualizar()
        {
            objDA.objVO = objVO;
            objDA.Atualizar();
        }

        public void Excluir()
        {
            objDA.objVO = objVO;
            objDA.Excluir();
        }

        public bool getLogin()
        {
            objDA.objVO = objVO;
            DataSet ds = objDA.getLogin();

            if (ds.Tables[0].Rows.Count > 0)
            {
                objVO.Nome = ds.Tables[0].Rows[0]["Nome"].ToString();
                objVO.Login = ds.Tables[0].Rows[0]["Login"].ToString();
                objVO.Senha = ds.Tables[0].Rows[0]["Senha"].ToString();
                objVO.DataNascimento = DateTime.Parse(ds.Tables[0].Rows[0]["DataNascimento"].ToString());
                objVO.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                objVO.IdLevel = int.Parse(ds.Tables[0].Rows[0]["idLevel"].ToString());
                objVO.IdUnidade = int.Parse(ds.Tables[0].Rows[0]["idUnidade"].ToString());
                objVO.IdUsuario = int.Parse(ds.Tables[0].Rows[0]["idUsuario"].ToString());

                return true;
            }
            else
            {
                return false;
            }
        }

        public DataSet getTodosRegistros()
        {
            return objDA.getTodosRegistros();
        }

        public DataSet getRegistroById()
        {
            objDA.objVO = objVO;
            return objDA.getRegistroById();
        }

        //public DataSet pegaId1()
        //{
        //    objDA.objVO = objVO;
        //    return objDA.pegaId1();
        //}

    }
}